import requests


class EmpManagerApi:
    def add_emp(self,req_headers,req_body):
        return requests.post(url="http://ihrm2-test.itheima.net/api/sys/user",
                             headers=req_headers,
                             json=req_body)

    def select_emp(self,emp_id,req_headers):
        return requests.get(url="http://ihrm2-test.itheima.net/api/sys/user/"+emp_id,
                            headers=req_headers)

    def updata_emp(self,emp_id,req_headers,req_body):
        return requests.get(url="http://ihrm2-test.itheima.net/api/sys/user/" + emp_id,
                            headers=req_headers,
                            json=req_body)
    def delect_emp(self,emp_id,req_headers):
        return requests.get(url="http://ihrm2-test.itheima.net/api/sys/user/" + emp_id,
                            headers=req_headers)
if __name__ == '__main__':
    emp = EmpManagerApi()
    req_headers ={"Authorization": "49116f1d-e274-419a-82a4-9144dd2cf0d3"}
    # req_body = {
    #                      "username": "user87655430",
    #                      "mobile": "13945864780",
    #                      "workNumber": "9527890aa"
    #                  }
    #
    # resp = emp.add_emp(req_headers,req_body)
    # print("添加成功",resp.json())
    emp_id = '1584101159440756736'

    # resp = emp.select_emp(emp_id,req_headers)
    # print("查询成功",resp.json())
    # req_body = {"username": "至宗宝99"}
    # resp = emp.updata_emp(emp_id,req_headers,req_body)
    # print(resp.json())
    resp = emp.delect_emp(emp_id,req_headers)
    print(resp.json())

